{% extends 'dcim/device/base.html' %}
{% load render_table from django_tables2 %}
{% load helpers %}
{% load static %}

{% block content %}
    <form method="post">
        {% csrf_token %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Power Ports</strong>
                <div class="pull-right noprint">
                    {% if request.user.is_authenticated %}
                        <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#DevicePowerPortTable_config" title="Configure table"><i class="mdi mdi-cog"></i> Configure</button>
                    {% endif %}
                </div>
            </div>
            {% render_table powerport_table 'inc/table.html' %}
            <div class="panel-footer noprint">
                {% if perms.dcim.change_powerport %}
                    <button type="submit" name="_rename" formaction="{% url 'dcim:powerport_bulk_rename' %}?return_url={% url 'dcim:device_powerports' pk=object.pk %}" class="btn btn-warning btn-xs">
                        <span class="mdi mdi-pencil" aria-hidden="true"></span> Rename
                    </button>
                    <button type="submit" name="_edit" formaction="{% url 'dcim:powerport_bulk_edit' %}?device={{ object.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}" class="btn btn-warning btn-xs">
                        <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit
                    </button>
                    <button type="submit" name="_disconnect" formaction="{% url 'dcim:powerport_bulk_disconnect' %}?return_url={% url 'dcim:device_powerports' pk=object.pk %}" class="btn btn-danger btn-xs">
                        <span class="mdi mdi-ethernet-cable-off" aria-hidden="true"></span> Disconnect
                    </button>
                {% endif %}
                {% if perms.dcim.delete_powerport %}
                    <button type="submit" name="_delete" formaction="{% url 'dcim:powerport_bulk_delete' %}?return_url={% url 'dcim:device_powerports' pk=object.pk %}" class="btn btn-danger btn-xs">
                        <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete
                    </button>
                {% endif %}
                {% if perms.dcim.add_powerport %}
                    <div class="pull-right">
                        <a href="{% url 'dcim:powerport_add' %}?device={{ object.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}" class="btn btn-xs btn-primary">
                            <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add power port
                        </a>
                    </div>
                {% endif %}
                <div class="clearfix"></div>
            </div>
        </div>
    </form>
    {% table_config_form powerport_table %}
{% endblock %}

{% block javascript %}
  <script src="{% static 'js/connection_toggles.js' %}?v{{ settings.VERSION }}"></script>
  <script src="{% static 'js/tableconfig.js' %}?v{{ settings.VERSION }}"></script>
{% endblock %}
